package Swing;

import javax.swing.*;
import java.awt.*;

public class JPanel_Demo extends JFrame {
    public JPanel_Demo()  {
        Container contentPane = this.getContentPane();
        contentPane.setLayout(new GridLayout(2,1,10,10) );//后面两个参数是间距
        JPanel panel = new JPanel(new GridLayout(1,3));
        panel.add(new Button("1"));
        panel.add(new Button("2"));
        panel.add(new Button("3"));
        contentPane.add(panel);
        this.setSize(500,500);
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    }

    public static void main(String[] args) {
        new JPanel_Demo();
    }
}
